Fix flaky Capybara tests with Chosen.js dropdowns#2453
Merged
olleolleolle merged 1 commit intocodebar:masterfrom Feb 2, 2026
Merged
Fix flaky Capybara tests with Chosen.js dropdowns#2453olleolleolle merged 1 commit intocodebar:masterfrom
olleolleolle merged 1 commit intocodebar:masterfrom
Conversation
Resolves issues with two failing feature tests that were timing-dependent when interacting with Chosen.js select dropdowns. Changes: - Rewrote select_from_chosen helper to use JavaScript instead of simulating clicks - Increased Capybara.default_max_wait_time to 5 seconds for JS tests - Added explicit waits for Chosen dropdown initialization - Used select_from_chosen helper consistently across tests The new approach directly sets select values via JavaScript and triggers Chosen's update events, avoiding race conditions from clicking and typing into the animated dropdown UI. All 777 tests now pass consistently with seed 63863.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
select_from_chosentest helper to be more reliableProblem
Two feature tests were failing locally due to race conditions when interacting with Chosen.js select dropdowns:
spec/features/member_feedback_spec.rb:60- Submitting feedbackspec/features/admin/manage_workshop_attendances_spec.rb:44- RSVPing membersThe original
select_from_chosenhelper tried to click the Chosen UI and type text, which was unreliable because:Solution
Rewrote
select_from_chosenhelper to:This approach:
Additional improvements:
Capybara.default_max_wait_timeto 5 seconds for better JS test stabilityTest Results
All tests pass with the same seed (63863) that previously caused failures.
Test plan
bundle exec rspecbundle exec rspec --seed 63863